
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="renderer" content="webkit" />
<title>主页</title>

<link rel="stylesheet" type="text/css" href="../../../plugins/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../../../plugins/jquery-easyui/1.8.6/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css" href="../../../plugins/jquery-easyui/1.8.6/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="../../../plugins/bootstrap/3.3.7/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="../../../plugins/font-awesome/css/font-awesome.min.css" />
    
<link rel="stylesheet" href="../../../plugins/zTree_v3/css/zTreeStyle/zTreeStyle.css" media="all" />
    
<link rel="stylesheet" type="text/css" href="../../../plugins/codemirror/lib/codemirror.css" />
<link rel="stylesheet" type="text/css" href="../../../plugins/codemirror/theme/dracula.css" />
<link rel="stylesheet" type="text/css" href="../../../plugins/codemirror/addon/hint/show-hint.css" />
<link rel="stylesheet" type="text/css" href="../../../plugins/codemirror/addon/display/fullscreen.css">
<link rel="stylesheet" type="text/css" href="../../../plugins/codemirror/addon/dialog/dialog.css">
<link rel="stylesheet" type="text/css" href="../../../plugins/codemirror/addon/search/matchesonscrollbar.css">
    
<link rel="stylesheet" type="text/css" href="../../../css/zbootstrap.css" />
<link rel="stylesheet" type="text/css" href="../../../css/zeasyui.css" />
<link rel="stylesheet" type="text/css" href="../../../css/common.css" />
    
<script type="text/javascript" src="../../../plugins/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="../../../plugins/jquery-rstorage/1.3.2/jquery.rStorage.min.js"></script>
<script type="text/javascript" src="../../../plugins/jquery-easyui/1.8.6/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../../plugins/jquery-form/4.3.0/jquery.form.min.js"></script>
    
<script type="text/javascript" src="../../../plugins/zTree_v3/js/jquery.ztree.all.js"></script>
<script type="text/javascript" src="../../../plugins/zTree_v3/js/jquery.ztree.exhide.js"></script>
    
<script type="text/javascript" src="../../../plugins/codemirror/lib/codemirror.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/mode/xml/xml.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/mode/css/css.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/hint/xml-hint.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/hint/show-hint.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/hint/html-hint.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/hint/css-hint.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/hint/javascript-hint.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/hint/anyword-hint.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/selection/selection-pointer.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/display/autorefresh.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/display/placeholder.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/edit/matchbrackets.js"></script>
<script type="text/javascript" src="../../../plugins/codemirror/addon/display/fullscreen.js"></script>
    
<script type="text/javascript" src="../../../js/zGlobal.js"></script>
<script type="text/javascript" src="../../../js/zApi.js"></script>
<script type="text/javascript" src="../../../js/zUtil.js"></script>
<script type="text/javascript" src="../../../js/zAlert.js"></script>
<script type="text/javascript" src="../../../js/zDict.js"></script>
<script type="text/javascript" src="../../../js/zTable.js"></script>
<script type="text/javascript" src="../../../js/zDialog.js"></script>
<script type="text/javascript" src="../../../js/zForm.js"></script>
    
    <![if IE]>

    <![endif]>

</head>
<body onload="noright(document.body);">

    <div id="p-all" class="easyui-layout" data-options="fit:true,border:false," style="border: 0px solid #D8D9E5;"> 
     <div data-options="region:'center',split:false,border:false" style="overflow: hidden;width:100%;border-right:1px solid rgb(210, 208, 208);"> 
      <table id="table-left"></table> 
     </div> 
    </div> 

  <!---分割-------------------------------------------------------------------------------->
  <div id="dlg-add-left" style="display:none;"> 
   <div class="main-content"> 
    <form>
     <div class="row">&nbsp;</div> 
     <div class="row padding-right"> 
     <div class="col-sm-12"> 
          <div class="row" style="padding: 3px;"> 
           <fieldset style="border: 1px solid #e5e5e5;padding-bottom: 5px;"> 
              <legend class=" text-info">说明</legend>
              <span class="description-title">用途：</span><span class="description-text">用于在代码生成配置编辑页面中的“简易可视化”功能使用，模拟页面展示效果</span>
              <span class="description-title">模板优先级：</span><span class="description-text">所属模块 > 所属项目 > 默认</span>
           </fieldset>
          </div> 
     </div>
     <div class="col-sm-6"> 
      <label class="form-lable">所属项目</label> 
      <div class="input-block">
        <select class="easyui-combobox" id="projectId" name="projectId" data-options="required:true,prompt:'可直接选模块'" style="width:100%;" ></select>
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">所属模块</label> 
      <div class="input-block"> 
        <select class="easyui-combobox" id="moduleId" name="moduleId" data-options="prompt:'可直接选模块'" style="width:100%;" ></select>
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">模板标题</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="templateTitle" name="templateTitle" data-options="required:true" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">排序</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="orderNum" name="orderNum" data-options="validType : ['number']" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-12"> 
      <label class="form-lable">备注</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="remarks" name="remarks" data-options="multiline:true,height:80" style="width:100%;" /> 
      </div> 
     </div> 
     
     </div> 
    </form> 
   </div> 
  </div>


  <div id="dlg-edit-left" style="display:none;"> 
   <div class="main-content"> 
    <form>
     <div class="row">&nbsp;</div>
     <div class="row padding-right"> 
     <div class="col-sm-6"> 
      <label class="form-lable">模板主键ID</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="templateId" name="templateId" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">所属项目</label> 
      <div class="input-block"> 
        <select class="easyui-combobox" id="projectId" name="projectId" data-options="required:true" style="width:100%;" ></select>
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">所属模块</label> 
      <div class="input-block"> 
        <select class="easyui-combobox" id="moduleId" name="moduleId" data-options="" style="width:100%;" ></select>
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">模板标题</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="templateTitle" name="templateTitle" data-options="required:true" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">模板路径</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="templatePath" name="templatePath" data-options="required:true" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">排序</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="orderNum" name="orderNum" data-options="validType : ['number']" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-12"> 
      <label class="form-lable">备注</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="remarks" name="remarks" data-options="multiline:true,height:80" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">状态</label> 
      <div class="input-block"> 
        <select class="easyui-combobox" id="dataStatus" name="dataStatus" data-options="" style="width:100%;" ></select>
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">创建用户ID</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="createOprid" name="createOprid" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">创建用户</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="createName" name="createName" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">创建时间</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="createTm" name="createTm" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">更新用户ID</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="lastUpdOprid" name="lastUpdOprid" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">更新用户</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="lastUpdName" name="lastUpdName" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     <div class="col-sm-6"> 
      <label class="form-lable">更新时间</label> 
      <div class="input-block"> 
        <input class="easyui-textbox" id="lastUpdTm" name="lastUpdTm" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     </div> 
    </form> 
   </div> 
  </div>

  <div id="dlg-query-left" style="display:none;">
   <div class="main-content">
    <form>
     <div class="row padding-right">
     <div class="col-sm-12"> 
      <label class="form-lable">所属项目</label> 
      <div class="input-block">
        <select class="easyui-combobox" id="projectId" name="projectId" data-options="" style="width:100%;" ></select>
      </div> 
     </div> 
     <div class="col-sm-12"> 
      <label class="form-lable">所属模块</label> 
      <div class="input-block">
        <select class="easyui-combobox" id="moduleId" name="moduleId" data-options="" style="width:100%;" ></select>
      </div> 
     </div> 
     <div class="col-sm-12"> 
      <label class="form-lable">模板标题</label> 
      <div class="input-block">
        <input class="easyui-textbox" id="templateTitle" name="templateTitle" data-options="" style="width:100%;" /> 
      </div> 
     </div> 
     </div> 
    </form>
   </div>
  </div>
  <!---分割-------------------------------------------------------------------------------->


  <div id="dlg-file-left" style="display:none;">
   <div class="main-content">
     <form enctype="multipart/form-data">
     <div class="row"> 
      <div class="col-sm-12"> 
       <label class="form-lable">上传文件</label> 
        <input class="easyui-filebox" id="fileObj" name="fileObj" data-options="required:true,prompt:'ftl',accept:'',accept:'',buttonText:'选择',validType:['fileSize[1,\'MB\']']" style="width:100%">
      </div> 
     </div>
    </form>
   </div>
   
  </div>

  <div id="dlg-code-online-look" style="display:none;overflow: hidden;">
   <div class="main-content">
     <div style="height:100%;position: relative;border: 1px solid #D2D2D2;">
         <textarea id="fileContent" style="display: none;"></textarea>
      </div>
   </div>
  </div>

 <script>
  TableToggleFlag = true;//默认开启联动
  TableSelectFlag = null;//默认未选中
  DictNames = {};
  
  /* --分割------------------------------------------------------------------------------ */
  
  TitleLeft = "可视化模板";
  IdDlgAddLeft = "#dlg-add-left";
  IdDlgEditLeft = "#dlg-edit-left";
  IdDlgQueryLeft = "#dlg-query-left";
  IdTableLeft = "#table-left";
  TableHeaderLeftMenu = null;
  
  /* --分割------------------------------------------------------------------------------ */
  IdDlgFileLeft = "#dlg-file-left";
  
  $(function(){
     loadDictToPage();//字典
     
    var urlLeft = zGlobal["http"] + "/autocode/previewTemplate/list";
    var buttonsIdxLeft = [0,3,4];
    var buttonsFuncLeft = [dlgAddLeft,dlgDelLeftTemplate,dlgQueryLeft];
    var optionsLeft = {
            queryParams:{},
            url : urlLeft,
            idField: 'templateId',
            sortName: 'createTm',
            sortOrder: 'desc',
            multiSort: true,
            columns:[[
                {field: 'templateId', title: '模板主键ID', align: 'center', width: 100, hidden: true},
                {field: 'projectId', title: '所属项目', align: 'left',halign: 'center', width: 100,sortable: true, formatter: function(value,rowData,rowIndex){ return zUtil.dictConvertOfAutocode(value,"ZSELECT_PROJECT")}},
                {field: 'moduleId', title: '所属模块', align: 'left',halign: 'center', width: 100, formatter: function(value,rowData,rowIndex){ return zUtil.dictConvertOfAutocode(value,"ZSELECT_PROJECT_MODULE")}},
                {field: 'templatePath', title: '模板路径', align: 'left',halign: 'center', width: 150},
                {field: 'orderNum', title: '排序', align: 'center', width: 50,sortable: true},
                {field: 'dataStatus', title: '状态', align: 'center', width: 50, formatter: function(value,rowData,rowIndex){ return zUtil.dictConvertOfAutocode(value,"dict.dataStatus")}},
                {field: 'createName', title: '创建用户', align: 'center', width: 100},
                {field: 'createTm', title: '创建时间', align: 'center', width: 135,sortable: true},
                {field: ' ', title: ' ', align: 'center', width: 100},
            ]],
            frozenColumns:[[
//              {field:'', title:'', align:'center', checkbox:true},
             {field:'buttonArr', title:'操作', align:'center', width: 60, formatter:buttonsFormatterLeft},
             {field: 'templateTitle', title: '模板标题', align: 'left',halign: 'center', width: 160},
            ]],
            onDblClickCell: function(rowIndex, field, value){
                if("buttonArr" != field){
                    dlgDtlLeft(rowIndex);
                }
            },
            onHeaderContextMenu: function(e, field){
              TableHeaderLeftMenu = zUtil.tableHeaderMenu(e,TableHeaderLeftMenu,IdTableLeft);
            },
            onRowContextMenu: function(e, rowIndex, rowData){
              e.preventDefault();
              zUtil.tableSelected(IdTableLeft,rowIndex);
              if(rowData != null){
                  dlgEditLeft(rowData);
              }
            },
    };
    zUtil.tableInit(IdTableLeft,optionsLeft,buttonsIdxLeft,buttonsFuncLeft);
        
    /* --分割------------------------------------------------------------------------------ */
    
  });
  
  function loadDictToPage(){
      var returnHandler = function(dict){
           zDictAutocode = dict;
           DictNames['ZSELECT_PROJECT'] = 'projectId';
           DictNames['ZSELECT_PROJECT_MODULE'] = 'moduleId';
           DictNames['dict.dataStatus'] = 'dataStatus';
           
           var linkSelsetIds = [IdDlgQueryLeft,IdDlgAddLeft,IdDlgEditLeft];
           $.each(linkSelsetIds,function(i,item){
               zUtil.selectFill(item,DictNames,zDictAutocode);
               
               zUtil.inputInit(item +" #projectId",'select',{
                   onSelect: function(data){
                       if(!data){return;}
                       zUtil.selectClear(item +" #moduleId");
                       DictNames = {};
                       DictNames["ZSELECT_PROJECT_MODULE_"+data["value"]] = "moduleId";
                       zUtil.selectFill(item, DictNames, zDictAutocode);
                   },
                   onChange: function(newValue,oldValue){
                       if(newValue){return;}
                       zUtil.val(item +" #moduleId", null);
                       DictNames = {};
                       DictNames["ZSELECT_PROJECT_MODULE"] = "moduleId";
                       zUtil.selectFill(item, DictNames, zDictAutocode);
                   }
               });
               
               zUtil.inputInit(item +" #moduleId",'select',{
                   onSelect: function(data){
                       if(!data){return;}
                       zUtil.val(item +" #projectId",data['projectId']);
                   },
               });
           });
      };
      zUtil.dictLoadOfAutocode("dict.dataStatus,ZSELECT_PROJECT,ZSELECT_PROJECT_MODULE"
          ,null,returnHandler);
  }
  
  /* --分割------------------------------------------------------------------------------ */
  
  //TODO
  function buttonsFormatterLeft(value,rowData,rowIndex){
    return '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="dlgDelLeft('+rowIndex+');" title="删除" ><i class="fa fa-trash"> </i></a> '
         +'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="dlgFileLeft('+rowIndex+');" title="上传/同步"><i class="fa fa-upload"> </i></a> '
         +'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="dlgOnlineLookCode('+rowIndex+');" title="在线编辑" ><i class="fa fa-eye"> </i></a>'
         ;
  }
  //TODO
  function dlgQueryLeft(){
    var dlgSave = function(){
      var params = zUtil.valAll(IdDlgQueryLeft);
      zUtil.tableQuery(IdTableLeft,params);
      zUtil.tableUnSelected(IdTableLeft);
      TableSelectFlag = null;
    };
    var dlgClear = function(){
      zUtil.formClear(IdDlgQueryLeft + ' form');
    };
    var dlgClose = function(){
      zUtil.dialogClose(IdDlgQueryLeft);
    };
    var dlgOptions = {
      title: TitleLeft + '-查询',
    };
    var dlgButtonsIdx = [0,1,2];
    var dlgButtonsFunc =  [dlgSave,dlgClear,dlgClose];
    zUtil.queryInit(IdDlgQueryLeft,dlgOptions,dlgButtonsIdx,dlgButtonsFunc);
    zUtil.dialogOpen(IdDlgQueryLeft);
  };
  //TODO
  function dlgQueryxLeft(){
    //zUtil.dialogOpen(IdDlgQueryxLeft);
  };
  //TODO
  function dlgAddLeft(){
    zUtil.formClear(IdDlgAddLeft + ' form');
    zUtil.readonlyAll(IdDlgAddLeft,false);
    
    var dlgSave = function(){
      if(!zUtil.formCheck(IdDlgAddLeft +' form')){
        return false;
      };
      var params = zUtil.valAll(IdDlgAddLeft);
      var reqData = {reqData: params};
      zUtil.ajaxPost(zGlobal["http"] + "/autocode/previewTemplate/add", reqData
      ,function(result){
        if(zCode["GLOBAL_SUCCESS"] == zUtil.getVal(result,zConst["busCode"])){
          var params = zUtil.valAll(IdDlgQueryLeft);
          zUtil.tableQuery(IdTableLeft,params);
          zUtil.dialogClose(IdDlgAddLeft);
        }else{
          zUtil.msg('保存失败'+(result.busMsg?'. '+result.busMsg:''));
        }
      });
      
    };
    var dlgClose = function(){
      zUtil.dialogClose(IdDlgAddLeft);
    };
    var dlgOptions = {
       title: TitleLeft + '-新增',
    };
    var dlgButtonsIdx = [0,1];
    var dlgButtonsFunc =  [dlgSave,dlgClose];
    zUtil.dialogInit(IdDlgAddLeft,dlgOptions,dlgButtonsIdx,dlgButtonsFunc);   
    zUtil.dialogOpen(IdDlgAddLeft);
  };
  //TODO  
  function dlgEditLeft(row){
    if($.isNumeric(row)){
      zUtil.tableSelected(IdTableLeft,row);
      row = zUtil.tableRows(IdTableLeft);
    }
    
    zUtil.formClear(IdDlgEditLeft + ' form');
    zUtil.readonlyAll(IdDlgEditLeft,false);
    zUtil.readonly(IdDlgEditLeft + ' #templateId');
    zUtil.readonly(IdDlgEditLeft + ' #projectId');
    zUtil.readonly(IdDlgEditLeft + ' #moduleId');
    zUtil.readonly(IdDlgEditLeft + ' #templatePath');
    zUtil.readonly(IdDlgEditLeft + ' #dataStatus');
    zUtil.readonly(IdDlgEditLeft + ' #createOprid');
    zUtil.readonly(IdDlgEditLeft + ' #createName');
    zUtil.readonly(IdDlgEditLeft + ' #createTm');
    zUtil.readonly(IdDlgEditLeft + ' #lastUpdOprid');
    zUtil.readonly(IdDlgEditLeft + ' #lastUpdName');
    zUtil.readonly(IdDlgEditLeft + ' #lastUpdTm');
    
    var dlgSave = function(){
      if(!zUtil.formCheck(IdDlgEditLeft +' form')){
        return false;
      }
      var params = zUtil.valAll(IdDlgEditLeft);
      var reqData = {reqData: params};
      zUtil.ajaxPost(zGlobal["http"] + "/autocode/previewTemplate/edit", reqData
      ,function(result){
        if(zCode["GLOBAL_SUCCESS"] == zUtil.getVal(result,zConst["busCode"])){
          var params = zUtil.valAll(IdDlgQueryLeft);
          zUtil.tableQuery(IdTableLeft,params);
          zUtil.dialogClose(IdDlgEditLeft);
        }else{
          zUtil.msg('保存失败'+(result.busMsg?'. '+result.busMsg:''));
        }
      });
    };
    var dlgClose = function(){
      zUtil.dialogClose(IdDlgEditLeft);
    };
    var dlgOptions = {
      title: TitleLeft + '-编辑',
      onOpen : function(){
        var params = {};
        params['templateId']  = row['templateId'];
        zUtil.ajaxPost(zGlobal["http"] + "/autocode/previewTemplate/detail", {reqData:params}
        ,function(result){
            if(zCode["GLOBAL_SUCCESS"] != zUtil.getVal(result,zConst["busCode"])){
              zUtil.msg('获取信息失败');
              return false;
            }
            zUtil.valAll(IdDlgEditLeft,result[zConst["resData"]]);
        });
      }
    };
    var dlgButtonsIdx = [0,1];
    var dlgButtonsFunc =  [dlgSave,dlgClose];
    zUtil.dialogInit(IdDlgEditLeft,dlgOptions,dlgButtonsIdx,dlgButtonsFunc);
    zUtil.dialogOpen(IdDlgEditLeft);
  };
  //TODO
  function dlgDtlLeft(row){
    if($.isNumeric(row)){
      zUtil.tableSelected(IdTableLeft,row);
      row = zUtil.tableRows(IdTableLeft);
    }
    zUtil.formClear(IdDlgEditLeft + ' form');
    zUtil.readonlyAll(IdDlgEditLeft);
          
    var dlgClose = function(){
      zUtil.dialogClose(IdDlgEditLeft);
    };
    var dlgOptions = {
      title: TitleLeft + '-详情',
      onOpen : function(){
        var params = {};
        params['templateId']  = row['templateId'];
        zUtil.ajaxPost(zGlobal["http"] + "/autocode/previewTemplate/detail", {reqData:params}
        ,function(result){
            if(zCode["GLOBAL_SUCCESS"] != zUtil.getVal(result,zConst["busCode"])){
              zUtil.msg('获取信息失败');
              return false;
            }
            zUtil.valAll(IdDlgEditLeft,result[zConst["resData"]]);
        });
      }
    };
    var dlgButtonsIdx = [1];
    var dlgButtonsFunc =  [dlgClose];
    zUtil.dialogInit(IdDlgEditLeft,dlgOptions,dlgButtonsIdx,dlgButtonsFunc);
    zUtil.dialogOpen(IdDlgEditLeft);
  };
  //TODO
  function dlgDelLeft(row){
    if($.isNumeric(row)){
      zUtil.tableSelected(IdTableLeft,row);
      row = zUtil.tableRows(IdTableLeft);
    }
    
    var params = {}; 
    params['templateId']  = row['templateId'];
    var reqData = {reqData: params};
    var okfunc = function(){
      zUtil.ajaxPost(zGlobal["http"] + "/autocode/previewTemplate/del", reqData
      ,function(result){
          if(zCode["GLOBAL_SUCCESS"] == zUtil.getVal(result,zConst["busCode"])){
            var params = zUtil.valAll(IdDlgQueryLeft);
            zUtil.tableQuery(IdTableLeft,params);
          }else{
            zUtil.msg('操作失败'+(result.busMsg?'. '+result.busMsg:''));
          }
      });
    }
    zUtil.msgConfirm("确认删除已选中记录?",okfunc);
  };
  //TODO 
  function dlgDelLeftTemplate(){
    var row = zUtil.tableRows(IdTableLeft);
    if(!row){
        zUtil.msg('请先选择记录');
        return false;
    }
    var params = {}; 
    params['templateId']  = row['templateId'];
    var reqData = {reqData: params};
    var okfunc = function(){
      zUtil.ajaxPost(zGlobal["http"] + "/autocode/previewTemplate/delTemplateAndDetail", reqData
      ,function(result){
        if(zCode["GLOBAL_SUCCESS"] == zUtil.getVal(result,zConst["busCode"])){
            var params = zUtil.valAll(IdDlgQueryLeft);
            zUtil.tableQuery(IdTableLeft,params);
        }else{
            zUtil.msg('操作失败');
            return false;
        }   
      });
    }
    zUtil.msgConfirm("删除模板记录?",okfunc);
  };
  
  function dlgFileLeft(row){
      if($.isNumeric(row)){
          zUtil.tableSelected(IdTableLeft,row);
          row = zUtil.tableRows(IdTableLeft);
      }
      zUtil.formClear(IdDlgFileLeft +' form');
      var paramsx = {};
      paramsx["templateId"] = row.templateId;
      
      var dlgSave = function(){
        if(!zUtil.formCheck(IdDlgFileLeft +' form')){
          return false;
        };
        var options = {
          url: zGlobal["http"] + '/autocode/uploadPreviewTemplate',
          type: 'post',
          data: paramsx
        };
        var result = zUtil.ajaxForm(IdDlgFileLeft + ' form', options)
        if(zCode["GLOBAL_SUCCESS"] == zUtil.getVal(result,zConst["busCode"])){
          var params = zUtil.valAll(IdDlgQueryLeft);
          zUtil.tableQuery(IdTableLeft,params);
          zUtil.formClear(IdDlgFileLeft +' form');
          zUtil.dialogClose(IdDlgFileLeft);
        }else{
          zUtil.msg('上传失败'+(result.busMsg?'. '+result.busMsg:''));
          return false;
        }
      };
      var dlgClose = function(){
        zUtil.dialogClose(IdDlgFileLeft);
      };
      
      var dlgOptions = {
          title: TitleLeft + '-上传',
          width: 400,
          height: 160,
          onOpen:function(){
          }
      };
      var dlgButtonsIdx = [0,1];
      var dlgButtonsFunc =  [dlgSave,dlgClose];
      
      zUtil.dialogInit(IdDlgFileLeft,dlgOptions,dlgButtonsIdx,dlgButtonsFunc);
      
      zUtil.dialogOpen(IdDlgFileLeft);
  };
  
  function dlgOnlineLookCode(row){
      if($.isNumeric(row)){
          zUtil.tableSelected(IdTableLeft,row);
          row = zUtil.tableRows(IdTableLeft);
      }else if('object' === $.type(row)){
        
      }
      
      var JSInfoDlgEditor = null;
      
      var dlgSave = function(){
           var content = JSInfoDlgEditor.getValue();
           
           var reqData = {reqData: {"templateFileId": row['templateId'], "fileContent": content} };
           zUtil.ajaxPost(zGlobal["http"] + "/autocode/savePreviewTemplateContent", reqData
           ,function(result){
            if(zCode["GLOBAL_SUCCESS"] == zUtil.getVal(result,zConst["busCode"])){
              zUtil.dialogClose('#dlg-code-online-look');
            }else{
              zUtil.msg('保存失败'+(result.busMsg?'. '+result.busMsg:''));
            }
          });
      };
      var dlgClose = function(){
        zUtil.dialogClose('#dlg-code-online-look');
      };
      var dlgOptions = {
         title: '在线编辑',
         onOpen:function(){
             var editorObj = $('#dlg-code-online-look #fileContent').next('.CodeMirror');
             if(editorObj.length === 0){
                JSInfoDlgEditor = CodeMirror.fromTextArea($('#dlg-code-online-look #fileContent')[0], {
                     autoRefresh:true,
                     lineNumbers: true,
                     styleActiveLine: true,
                     matchBrackets: true,
                     lineWrapping: true,
                     theme: 'dracula',
                     hintOptions: {
                         completeSingle: false,  //关闭补全
                     },
                     mode: "htmlmixed",
                     extraKeys: {
                         "F11": function(cm) {
                           cm.setOption("fullScreen", !cm.getOption("fullScreen"));
                         },
                         "Esc": function(cm) {
                           if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
                         }
                    }
                });
                JSInfoDlgEditor.setSize('100%','100%');
                JSInfoDlgEditor.on('keyup', () => {
                    //编译器内容更改事件
                    JSInfoDlgEditor.showHint();
                });
             }else{
                JSInfoDlgEditor = editorObj[0].CodeMirror;
             }
             
             var paramsx = {};
              paramsx['templateFileId'] = row['templateId'];
              zUtil.ajaxPost(zGlobal["http"] + "/autocode/getPreviewTemplateContent", {reqData:paramsx}
              ,function(detail){
                if(zCode["GLOBAL_SUCCESS"] != zUtil.getVal(detail,zConst["busCode"])){
                  zUtil.msg('获取信息失败');
                  return false;
                }
                detail = detail[zConst["resData"]];
                JSInfoDlgEditor.setValue(detail['fileContent']);
              });
         }
      };
      var dlgButtonsIdx = [0,1];
      var dlgButtonsFunc =  [dlgSave,dlgClose];
      zUtil.dialogInit('#dlg-code-online-look',dlgOptions,dlgButtonsIdx,dlgButtonsFunc);
      zUtil.dialogOpen('#dlg-code-online-look');
  }
  
  </script>

</body>
</html>